
#import "TabSettingViewController.h"
#import "AlertViewController.h"

#import "QQLBXScanViewController.h"
#import "LBXScanDiyStyleLib.h"
#import "LBXPermission.h"
#import "LBXPermissionSetting.h"

@interface TabSettingViewController ()

@property(nonatomic ,strong) NSArray* tableViewData;

@end

@implementation TabSettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    [self setTitle:@"设置"];
    
    self.tableViewData = @[@"扫一扫",@"进化版扫一扫",@"刘备",@"关羽",@"马超",@"孔明",@"魏延",@"姜维",@"刘禅"];
    
    self.tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    self.tableView.tableFooterView = [[UIView alloc]init];
    
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    static NSString * ID = @"ChecklizdvdzfbdzbstItem";
    UITableViewCell * cell =[tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
        cell.textLabel.text = self.tableViewData[indexPath.row];
    }
    return cell;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.tableViewData.count;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if( indexPath.row == 0){
        
        __weak __typeof(self) weakSelf = self;
        [LBXPermission authorizeWithType:LBXPermissionType_Camera completion:^(BOOL granted, BOOL firstTime) {
            if (granted) {
                
                //添加一些扫码或相册结果处理
                QQLBXScanViewController *vc = [QQLBXScanViewController new];
                vc.libraryType = SLT_ZXing;
                vc.scanCodeType = SCT_QRCode |
                SCT_BarCode93 |
                SCT_BarCode128 |
                SCT_BarCodeITF |
                SCT_BarEAN13;
                
                vc.style = [LBXScanDiyStyleLib qqStyle];
                
                //镜头拉远拉近功能
                vc.isVideoZoom = YES;
                [self.navigationController pushViewController:vc animated:YES];
                
            }
            else if(!firstTime)
            {
                [LBXPermissionSetting showAlertToDislayPrivacySettingWithTitle:@"提示" msg:@"没有相机权限，是否前往设置" cancel:@"取消" setting:@"设置" ];
            }
        }];
   
        
        
        
    }
    else if(indexPath.row == 1){
       
    }
    return;
    
    UIAlertController *alert = [AlertViewController Alert:@"吩咐" callbackOkFn:^(){
        NSLog(@"1111111111");
        
        NSArray* arr = @[@"1",@"2",@"3",@"4"];
        UIAlertController *sheetsAlert = [AlertViewController AlertSheet:@"提示" message:@"abc" sheetsName:arr callbackFns:^(int index){
            NSLog(@"%@", arr[index]);
        }];
        [self presentViewController:sheetsAlert animated:YES completion:nil];
        
    }];
    
    [self presentViewController:alert animated:YES completion:nil];
    
}

-(void) TestUrl{
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
@end
